package online.misscl.lsy.util;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * project name: IntelliJ IDEA
 * Date: 2023/4/5 23:31
 *
 * @PackageName: online.misscl.lsy.util
 * @ClassName: SystemEnv
 * @Author: Theo
 * @Version:
 * @Description:
 */
@Slf4j
@Component
public class SystemEnv {

    @Value("${linux.upload-file-path}")
    String linuxUploadFilePath;

    @Value("${windows.upload-file-path}")
    String windowsUploadFilePath;

    /**
     *
     * @return window为true , linux为false
     */
    public static boolean getSystemEnv(){
        String os = System.getProperty("os.name");
        if (os != null && os.toLowerCase().startsWith("windows")) {
            log.info("当前系统为：{}",os);
            System.out.println(new SystemEnv().getEnvPath());
            return true;
        } else if (os != null && os.toLowerCase().startsWith("linux")) {
            log.info("当前系统为：{}",os);
            return false;
        }
        throw new RuntimeException("判断不了是window环境还是linux环境");
    }
    public String getEnvPath(){
        String os = System.getProperty("os.name");
        if (os != null && os.toLowerCase().startsWith("windows")) {
            log.info("当前系统为：{}",os);
            return "D:\\img\\";
        } else if (os != null && os.toLowerCase().startsWith("linux")) {
            log.info("当前系统为：{}",os);
            return "/data/lsy/";
        }
        throw new RuntimeException("判断不了是window环境还是linux环境");
    }



}
